﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace d1Project.Tools
{
    //自然语言处理工具
    public static class NLSHelper
    {
        public static string text2PinYin(string _txt)
        {
            string PYstr = "";
            foreach (char item in _txt.ToCharArray())
            {
                if (Microsoft.International.Converters.PinYinConverter.ChineseChar.IsValidChar(item))
                {
                    Microsoft.International.Converters.PinYinConverter.ChineseChar cc = new Microsoft.International.Converters.PinYinConverter.ChineseChar(item);

                    PYstr += cc.Pinyins[0].Substring(0, cc.Pinyins[0].Length - 1);
                }
                else
                {
                    PYstr += item.ToString();
                }
            }
            return PYstr;
        }
    }
}